package com.github.baichuan.application.scaffold.rest.gateway.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

import java.util.concurrent.TimeUnit;

@Configuration
public class WebFluxConfig implements WebFluxConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/*")
                .addResourceLocations("file:./public/");

        registry.addResourceHandler("/assets/**")
                .addResourceLocations("file:./public/assets/")
                .setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS))
                .resourceChain(true);
//
//        registry.addResourceHandler("/js/**")
//                .addResourceLocations("file:./public/js/")
//                .setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS))
//                .resourceChain(true);
//
//        registry.addResourceHandler("/resource/**")
//                .addResourceLocations("file:./public/resource/")
//                .setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS))
//                .resourceChain(true);
//
//        registry.addResourceHandler("/static/**")
//                .addResourceLocations("classpath:/static/");
    }
}
